<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
	<title>确认订单</title>
</head>
<body>
	<!-- header.jsp -->
	<jsp:include page="../header.jsp"></jsp:include>
	<!-- /header.jsp -->

	<!-- SECTION -->
	<div class="section">
		<!-- container -->
		<div class="container">
			<!-- row -->
			<div class="row">
				<div class="col-md-12">

					<div class="table-responsive">
						<table class="table table-bordered" style="text-align: center;">
							<caption>订单详情</caption>
							<tbody>
								<tr style="font-weight: bold;">
									<td>订单所含商品</td>
									<td>订单状态</td>
									<td>订单金额</td>
									<td>下单时间</td>
									<td>订单编号</td>
								</tr>
								<tr>
									<td style="vertical-align: middle;">
										<table class="table table-bordered" style="text-align: center;">
											<tbody>
											<tr style="font-weight: bold;">
												<td>图片</td>
												<td>名称</td>
												<td>单价</td>
												<td>数量</td>
												<td>小计</td>
											</tr>
											<c:forEach items="${order.orderItems }" var="item">
												<tr>
													<td width="60" width="40%" style="vertical-align: middle;">
														<img src="${pageContext.request.contextPath}/${item.product.pimage}" width="70" height="60">
													</td>
													<td width="30%" style="vertical-align: middle;">
														<a target="_blank" href="${pageContext.request.contextPath}/product?method=productDetails&pid=${item.product.pid}">${item.product.pname}</a>
													</td>
													<td width="20%" style="vertical-align: middle;">
														￥${item.product.shop_price}
													</td>
													<td width="20%" style="vertical-align: middle;">
															${item.count}
													</td>
													<td width="15%" style="vertical-align: middle;">
														<span class="subtotal">${item.subTotal}</span>
													</td>
												</tr>
											</c:forEach>
											</tbody>
										</table>
									</td>
									<td style="vertical-align: middle;color: red;">
										<c:choose>
											<c:when test="${order.state == 0}">
												未付款
											</c:when>
											<c:when test="${order.state == 1}">
												已付款
											</c:when>
											<c:when test="${order.state == 2}">
												已发货
											</c:when>
											<c:when test="${order.state == 3}">
												已完成
											</c:when>
										</c:choose>
									</td>
									<td style="vertical-align: middle;">
										￥${order.total}
									</td>
									<td style="vertical-align: middle;">
										<fmt:formatDate value="${order.ordertime}" pattern="yyyy-MM-dd hh:mm:ss"></fmt:formatDate>
									</td>
									<td style="vertical-align: middle;">
										${order.oid}
									</td>
								</tr>
							</tbody>
						</table>

						<div style="text-align: right;">
							商品合计：<i class="fa fa-rmb" aria-hidden="true"></i>${order.total}
							<br>
							<br>
							<c:if test="${order.state == 0 && not empty order.address}">
								<button class="btn btn-danger" style="border-radius: 25px;background-color: #D10024;" onclick="payOrder('${order.oid}')">&nbsp;&nbsp; 去付款 &nbsp;&nbsp;</button>
							</c:if>
						</div>
						<c:if test="${empty order.address}">
							<div style="text-align: left;">
								请填写收货信息
								<br>
								<br>
							</div>
						</c:if>
						<c:if test="${not empty order.address}">
							<div style="text-align: left;">
								收货信息
								<br>
								<br>
							</div>
						</c:if>
					</div>

					<form class="form-horizontal" method="post" action="${pageContext.request.contextPath}/order">
						<input type="hidden" name="method" value="saveAddress">
						<div class="form-group">
							<div class="col-md-2">
								<label class="control-label">
									收货人：
								</label>
							</div>
							<div class="col-md-10">
								<input class="input" type="text" name="name" placeholder="收货人姓名" value="${user.name}" required <c:if test="${not empty order.address}">disabled</c:if>>
							</div>
						</div>

						<div class="form-group">
							<div class="col-md-2">
								<label class="control-label">
									电话号码：
								</label>
							</div>
							<div class="col-md-10">
								<input class="input" type="telephone" name="telephone" placeholder="电话号码" pattern="1[23456789]\d{9}" value="${user.telephone}" required <c:if test="${not empty order.address}">disabled</c:if>>
							</div>
						</div>

						<div class="form-group">
							<div class="col-md-2">
								<label class="control-label">
									收货地址：
								</label>
							</div>
							<div class="col-md-10">
								<input class="input" type="text" name="address" placeholder="收货地址" value="${order.address}" required <c:if test="${not empty order.address}">disabled</c:if>>
							</div>
						</div>
						<c:if test="${empty order.address}">
							<div class="form-group">
								<center>
									<button class="btn btn-danger" style="background-color: #D10024;" type="submit">&nbsp;&nbsp; 提交 &nbsp;&nbsp;</button>
									<button class="btn btn-danger" style="background-color: #D10024;" type="reset">&nbsp;&nbsp; 重置 &nbsp;&nbsp;</button>
								</center>
							</div>
						</c:if>
					</form>
				</div>
			</div>
			<!-- /row -->
		</div>
		<!-- /container -->
	</div>
	<!-- /SECTION -->

	<!-- footer.jsp -->
	<jsp:include page="../footer.jsp"></jsp:include>
	<!-- /footer.jsp -->

</body>
</html>
